<?php
require_once("database.php");
class xl_cau_hinh extends database
{
	function danh_sach($vi_tri, $so_luong)
	{
		$vi_tri = intval($vi_tri);
		$so_luong = intval($so_luong);
		$sql = "select * from cau_hinh limit $vi_tri, $so_luong";
		$this->setQuery($sql);
		return $this->loadAllRow();
	}
	function so_luong()
	{
		$sql = "select count(*) from cau_hinh";
		$this->setQuery($sql);
		return $this->loadResult();
	}
	function xem($tu_khoa)
	{
		$tu_khoa = stripslashes($tu_khoa);
		$tu_khoa = addslashes($tu_khoa);

		$sql = "select * from cau_hinh where tu_khoa = '$tu_khoa'";
		$this->setQuery($sql);
		return $this->loadRow();
	}
	function xoa($tu_khoa)
	{
		$tu_khoa = stripslashes($tu_khoa);
		$tu_khoa = addslashes($tu_khoa);

		$sql = "delete from cau_hinh where tu_khoa = '$tu_khoa'";
		$this->setQuery($sql);
		return $this->query();
	}
	function them($noi_dung)
	{
		$noi_dung = stripslashes($noi_dung);
		$noi_dung = addslashes($noi_dung);

		$sql = "INSERT INTO cau_hinh(noi_dung) VALUES ('$noi_dung')";
		$this->setQuery($sql);
		return $this->query();
	}
	function cap_nhat($tu_khoa, $noi_dung)
	{
		$tu_khoa = stripslashes($tu_khoa);
		$tu_khoa = addslashes($tu_khoa);
		$noi_dung = stripslashes($noi_dung);
		$noi_dung = addslashes($noi_dung);

		$sql ="UPDATE cau_hinh SET noi_dung= '$noi_dung' WHERE tu_khoa = '$tu_khoa'";
		$this->setQuery($sql);
		return $this->query();
	}
	function tim_kiem ($tu_khoa)
	{
		$sql = "select * from cau_hinh where	$noi_dung like %tu_khoa%"; 
		$this->setQuery($sql);
		return $this->loadAllRow();	
	}
 }
?>